#ifndef _PART_2D_H_
#define _PART_2D_H_


#include "part_group.h"


namespace part2d
{

/**
 * Particles for 2D Games (about time)
 */
class Part2D
{
public:
							Part2D();
							~Part2D();
    bool					Load(const std::string& File);
    bool					Save(const std::string& File);
	const std::string&		GetFile() const { return m_File; };
	bool					Render(const math::Vec2& Offset, float Scale = 1.0f, const math::Vec2& Min = math::Vec2(0,0), const math::Vec2& Max = math::Vec2(1,1) );
    bool					Tick(float dt);
	bool					TickCreation(float dt, const math::Vec2& Pos, const math::Vec2& Size); 
	Particle2D*	 			TriggerParticle(const math::Vec2& ScreenPos);
	Particle2D*				TriggerParticle(const math::Vec2& ScreenPos, const math::Vec2& InitialDir);
	Particle2D*				TriggerParticleAbs(const math::Vec2& ScreenPos, const math::Vec2& InitialDir);
	void					TriggerParticles(const math::Vec2& ScreenPos);
	void					TriggerParticles(const math::Vec2& ScreenPos, const math::Vec2& InitialDir);
	void					TriggerParticlesAbs(const math::Vec2& ScreenPos, const math::Vec2& InitialDir);
	void					TriggerParticlesOnLine(const math::Vec2& From, const math::Vec2& To);
	void					TriggerParticleSet(int Count, const math::Vec2& ScreenPos);
	void					TriggerParticleSet(int Count, const math::Vec2& ScreenPos, const math::Vec2& InitialDir);
	void					TriggerParticlesOnCircle(const math::Vec2& Pos, float Radius, bool CorrectAspectRatio = true);
	void					SetSizeScale(float SizeScale);

	// callback stuff
	void					SetDeathParticleCB(PartGroup::ParticleCallback pCB, void *pData);

	void					ResetGeom();
	void					AddGeom(const math::Vec2& Pos, float r);
	PartGroup*				CreateGroup();
	PartGroup*				GetGroup(unsigned int i);
	void					DeleteGroup(unsigned int i);
	void					DeleteGroup(PartGroup* pGroup);
	int						GroupC() const { return (int)m_Systems.size(); };

	void					SetPos(const math::Vec2& P) { m_Pos = P; };
	const math::Vec2&		GetPos() const  { return m_Pos; };

	Part2D*					Clone(Part2D* pClone = NULL);
	bool					IsActive();
	bool					IsInside(const math::Vec2& Pos);
	void					Clear();
	// accessors
	/// register with LUA Bind
	static	void		Register(LuaPlus::LuaState* _pScript);

protected:
	std::string				m_File;
	std::vector<PartGroup*>	m_Systems;
	math::Vec2				m_Pos;
};

};

#endif //_PART_2D_H_